From 6262be2b90de26a024e30f67428deb8aa698d480 Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 12 May 2006 20:50:34 +0000 Subject: [PATCH] Moster commit after sourceforge returns from the dead. Make filters, shapefile, csv support configurable away at runtime. Fix several problems with new XML_UNICODE code. Allow expat library configuration at build time Allow more custom waypoint icons in Garmin, bring in more category support. Many fixes to track stat recalculator. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@2040 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/arcdist.c | 2 + gpsbabel/cet_util.c | 75 +++++++++++++++++-- gpsbabel/cet_util.h | 1 + gpsbabel/coastexp.c | 5 +- gpsbabel/compegps.c | 2 + gpsbabel/config.h.in | 6 ++ gpsbabel/configure | 149 ++++++++++++++++++++++++++++++++----- gpsbabel/configure.in | 97 +++++++++++++++++++----- gpsbabel/csv_util.c | 6 +- gpsbabel/discard.c | 2 + gpsbabel/duplicate.c | 2 + gpsbabel/filter_vecs.c | 68 +++++++++-------- gpsbabel/garmin_tables.c | 63 ++++++---------- gpsbabel/garmin_txt.c | 6 +- gpsbabel/gpx.c | 5 +- gpsbabel/internal_styles.c | 77 ++++++++++--------- gpsbabel/interpolate.c | 2 + gpsbabel/jeeps/gps.h | 1 + gpsbabel/jeeps/gpsapp.c | 6 +- gpsbabel/mingw/Makefile | 2 +- gpsbabel/mkstyle.sh | 9 ++- gpsbabel/nukedata.c | 2 + gpsbabel/polygon.c | 2 + gpsbabel/position.c | 3 + gpsbabel/reverse_route.c | 3 + gpsbabel/sort.c | 3 + gpsbabel/stackfilter.c | 4 + gpsbabel/trackfilter.c | 3 +- gpsbabel/vecs.c | 10 +++ gpsbabel/xcsv.c | 5 ++ gpsbabel/xmlgeneric.c | 2 +- 31 files changed, 458 insertions(+), 165 deletions(-) diff --git a/gpsbabel/arcdist.c b/gpsbabel/arcdist.c index cbb8ced95..824960de5 100644 --- a/gpsbabel/arcdist.c +++ b/gpsbabel/arcdist.c @@ -22,6 +22,7 @@ #include "filterdefs.h" #include "grtcirc.h" +#if FILTERS_ENABLED #define MYNAME "Arc filter" static double pos_dist; @@ -168,3 +169,4 @@ filter_vecs_t arcdist_vecs = { NULL, arcdist_args }; +#endif FILTERS_ENABLED diff --git a/gpsbabel/cet_util.c b/gpsbabel/cet_util.c index 800051cac..d71f30248 100644 --- a/gpsbabel/cet_util.c +++ b/gpsbabel/cet_util.c @@ -1160,20 +1160,85 @@ int cet_fprintf(FILE *stream, const cet_cs_vec_t *src_vec, const char *fmt, ...) return res; } +/* + * 'str' points to an array of XML_Chars which may be UNICODE16 + * words in native endianness. + */ -const char *xml_convert_to_char_string(const XML_Char *str) +const char *xml_convert_to_char_string_n(const XML_Char *src, int *n) { #ifdef XML_UNICODE - return cet_str_uni_to_utf8(str, wcslen(str)); + char *utf8; + char *utf8b; + int i, j; + + /* + * '*n' is the number of source bytes. + * Walk over that, converting each character and + * discarding it, but tallying 'i' as the number of + * bytes in the destination string. + */ + i = 0; + for (j = 0; j < *n; j++) { + i += cet_ucs4_to_utf8(NULL, 6, src[j]); + } + + /* Update output byte count in caller. */ + *n = i; + + /* Appropriately size (not zero terminated) buffer */ + utf8 = utf8b = xmalloc(i); + + for (j = 0; utf8 < utf8b + i; j++) { + utf8 += cet_ucs4_to_utf8(utf8, 6, src[j]); + } + + return utf8b; +#else + return src; +#endif +} + +/* + * 'str' points to NULL terminated string of XML_Chars which + * may be UNICODE16 words in native endianness. + */ + +const char *xml_convert_to_char_string(const XML_Char *src) +{ +#ifdef XML_UNICODE + char *utf8; + char *utf8b; + int i, j; + const XML_Char *in = src; + + /* Walk source array until we find source terminator */ + i = 0; + for (j = 0; src[j]; j++) { + i += cet_ucs4_to_utf8(NULL, 6, src[j]); + } + + /* We return a NUL terminated string. */ + utf8 = utf8b = xmalloc(i + 1); + in = src; + + for (j = 0; utf8 < utf8b + i; j++) { + utf8 += cet_ucs4_to_utf8(utf8, 6, src[j]); + } + *utf8 = '\0'; + + return utf8b; + #else - return str; + return src; #endif } + void xml_free_converted_string(const char *str) { #ifdef XML_UNICODE - xfree(str); + xfree((void *) str); #endif } @@ -1210,7 +1275,7 @@ void xml_free_converted_attrs(const char **attr) { #ifdef XML_UNICODE while (attr != NULL && *attr != NULL) { - xfree(*attr); + xfree((void *)*attr); ++attr; } #endif diff --git a/gpsbabel/cet_util.h b/gpsbabel/cet_util.h index a5ac16247..96febcd88 100644 --- a/gpsbabel/cet_util.h +++ b/gpsbabel/cet_util.h @@ -121,6 +121,7 @@ void cet_disp_character_set_names(FILE *fout); * it. */ +const char *xml_convert_to_char_string_n(const XML_Char *str, int *nbytes); const char *xml_convert_to_char_string(const XML_Char *str); void xml_free_converted_string(const char *str); diff --git a/gpsbabel/coastexp.c b/gpsbabel/coastexp.c index 834663981..7c412e2ba 100755 --- a/gpsbabel/coastexp.c +++ b/gpsbabel/coastexp.c @@ -192,7 +192,8 @@ ce_end(void *data, const XML_Char *xml_el) static void ce_cdata(void *dta, const XML_Char *xml_s, int len) { - const char *s = xml_convert_to_char_string(xml_s); + const char *origs = xml_convert_to_char_string_n(xml_s, &len); + const char *s = origs; if (*s != '\n') { char *edatastr; // We buffer up characters in 'cdatastr' until a single is received @@ -304,7 +305,7 @@ ce_cdata(void *dta, const XML_Char *xml_s, int len) cdatastr[0] = '\0'; } - xml_free_converted_string(s); + xml_free_converted_string(origs); } /* Set up reading the CE input file */ diff --git a/gpsbabel/compegps.c b/gpsbabel/compegps.c index 992364153..be4b2fa17 100644 --- a/gpsbabel/compegps.c +++ b/gpsbabel/compegps.c @@ -58,6 +58,7 @@ #include "defs.h" #include "csv_util.h" +#if CSVFMTS_ENABLED #include #include #include @@ -637,3 +638,4 @@ ff_vecs_t compegps_vecs = { compegps_args, CET_CHARSET_MS_ANSI, 1 }; +#endif /* CSVFMTS_ENABLED */ diff --git a/gpsbabel/config.h.in b/gpsbabel/config.h.in index 10b5f9b90..29441673c 100644 --- a/gpsbabel/config.h.in +++ b/gpsbabel/config.h.in @@ -3,6 +3,12 @@ /* 0 for most-used character sets */ #undef CET_WANTED +/* 1 to enable the CSV formats support */ +#undef CSVFMTS_ENABLED + +/* 1 to enable all the filters. */ +#undef FILTERS_ENABLED + /* Defined if you have libexpat */ #undef HAVE_LIBEXPAT diff --git a/gpsbabel/configure b/gpsbabel/configure index a98bb78cc..6798e0f99 100755 --- a/gpsbabel/configure +++ b/gpsbabel/configure @@ -804,10 +804,20 @@ if test -n "$ac_init_help"; then esac cat <<\_ACEOF +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-shapefile=(yes)|no + --enable-pdb=(yes)|no + --enable-csv=(yes)|no + --enable-filters=(yes)|no + Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) ---with-cet=(default,all,minimal) + --with-cet=(default,all,minimal) + --with-expathdr=DIR Use this to specify the location of expat.h + --with-libexpat=DIR Use this to specify expat library . Some influential environment variables: CC C compiler command @@ -2521,16 +2531,94 @@ _ACEOF fi +echo "$as_me:$LINENO: checking whether to support shapefiles" >&5 +echo $ECHO_N "checking whether to support shapefiles... $ECHO_C" >&6 +# Check whether --enable-shapefile or --disable-shapefile was given. +if test "${enable_shapefile+set}" = set; then + enableval="$enable_shapefile" + enable_shapefile="$enableval" +else + enable_shapefile="yes" +fi; + if test "$enable_shapefile" != "no" ; then cat >>confdefs.h <<\_ACEOF #define SHAPELIB_ENABLED 1 _ACEOF + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + fi + +echo "$as_me:$LINENO: checking whether to support Palm/OS pdb formats" >&5 +echo $ECHO_N "checking whether to support Palm/OS pdb formats... $ECHO_C" >&6 +# Check whether --enable-pdb or --disable-pdb was given. +if test "${enable_pdb+set}" = set; then + enableval="$enable_pdb" + enable_pdb="$enableval" +else + enable_pdb="yes" +fi; + if test "$enable_pdb" != "no" ; then cat >>confdefs.h <<\_ACEOF #define PDBFMTS_ENABLED 1 _ACEOF + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + fi + +echo "$as_me:$LINENO: checking whether to support csv formats" >&5 +echo $ECHO_N "checking whether to support csv formats... $ECHO_C" >&6 +# Check whether --enable-csv or --disable-csv was given. +if test "${enable_csv+set}" = set; then + enableval="$enable_csv" + enable_csv="$enableval" +else + enable_csv="yes" +fi; + if test "$enable_csv" != "no" ; then + +cat >>confdefs.h <<\_ACEOF +#define CSVFMTS_ENABLED 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + fi + +echo "$as_me:$LINENO: checking whether to support csv formats" >&5 +echo $ECHO_N "checking whether to support csv formats... $ECHO_C" >&6 +# Check whether --enable-filters or --disable-filters was given. +if test "${enable_filters+set}" = set; then + enableval="$enable_filters" + enable_filters="$enableval" +else + enable_filters="yes" +fi; + if test "$enable_filters" != "no" ; then + +cat >>confdefs.h <<\_ACEOF +#define FILTERS_ENABLED 1 +_ACEOF + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + fi + case "$target" in *-*-cygwin* | *-*-mingw32*) @@ -2705,30 +2793,55 @@ echo $ECHO_N "checking for random stuff to make you feel better... $ECHO_C" >&6 echo "$as_me:$LINENO: result: failed" >&5 echo "${ECHO_T}failed" >&6 -echo "$as_me:$LINENO: checking for libexpat" >&5 -echo $ECHO_N "checking for libexpat... $ECHO_C" >&6 -if test "$with_libexpat" = no ; then - echo "$as_me:$LINENO: result: check not done" >&5 -echo "${ECHO_T}check not done" >&6 + +# Check whether --with-expathdr or --without-expathdr was given. +if test "${with_expathdr+set}" = set; then + withval="$with_expathdr" + xpathdr="$withval" else -# Special case fink test. case "$target" in *-*-darwin*) - if test -f /sw/include/expat.h -a -f /sw/include/expat.h; then - CFLAGS="$CFLAGS -I/sw/include" - LDFLAGS="$LDFLAGS -L/sw/lib" - # Static link against expat archive, not dyn lib. + if test -f /sw/include/expat.h ; then + xpathdr=/sw/include/ + fi + ;; + *) ;; + esac -cat >>confdefs.h <<\_ACEOF -#define HAVE_LIBEXPAT 1 -_ACEOF +fi; + +if test "x-$xpathdr " != "x-" ; then + CFLAGS="$CFLAGS -I$xpathdr" +fi + +echo "$as_me:$LINENO: checking for libexpat" >&5 +echo $ECHO_N "checking for libexpat... $ECHO_C" >&6 + +# Check whether --with-libexpat or --without-libexpat was given. +if test "${with_libexpat+set}" = set; then + withval="$with_libexpat" + EXPAT_LIB="-L$withval -lexpat" +else + + case "$target" in + *-*-darwin*) + if test -f /sw/lib/libexpat.a ; then EXPAT_LIB=/sw/lib/libexpat.a fi ;; *) - echo "$as_me:$LINENO: checking for XML_ParserCreate in -lexpat" >&5 + EXPAT_LIB=-lexpat + ;; + esac + + +fi; +echo "$as_me:$LINENO: result: $EXPAT_LIB" >&5 +echo "${ECHO_T}$EXPAT_LIB" >&6 + +echo "$as_me:$LINENO: checking for XML_ParserCreate in -lexpat" >&5 echo $ECHO_N "checking for XML_ParserCreate in -lexpat... $ECHO_C" >&6 if test "${ac_cv_lib_expat_XML_ParserCreate+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -2798,14 +2911,12 @@ cat >>confdefs.h <<\_ACEOF #define HAVE_LIBEXPAT 1 _ACEOF - EXPAT_LIB="$LDFLAGS -lexpat" -fi +# [EXPAT_LIB="$LDFLAGS -lexpat"] - ;; - esac fi +echo $EXPAT_LIB # Checks for header files. # AC_HEADER_STDC diff --git a/gpsbabel/configure.in b/gpsbabel/configure.in index 797244550..2067ea677 100644 --- a/gpsbabel/configure.in +++ b/gpsbabel/configure.in @@ -20,7 +20,7 @@ AC_SUBST(AC_EXEEXT) # Checks for libraries. AC_CHECK_LIB([m], [cos]) -AC_ARG_WITH(cet,[--with-cet=(default,all,minimal)], +AC_ARG_WITH(cet,[ --with-cet=(default,all,minimal)], cet="$withval", cet="default") if test "$cet" = "all"; then @@ -30,8 +30,50 @@ if test "$cet" = "default"; then AC_DEFINE(CET_WANTED, 0, [0 for most-used character sets]) fi -AC_DEFINE(SHAPELIB_ENABLED, 1, [1 to enable shapefile support]) -AC_DEFINE(PDBFMTS_ENABLED, 1, [1 to enable Palm PDB support]) +AC_MSG_CHECKING(whether to support shapefiles) +AC_ARG_ENABLE(shapefile, + [ --enable-shapefile=[(yes)|no]], + [ enable_shapefile="$enableval"],[enable_shapefile="yes"]) + if test "$enable_shapefile" != "no" ; then + AC_DEFINE(SHAPELIB_ENABLED, 1, [1 to enable shapefile support]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + +AC_MSG_CHECKING(whether to support Palm/OS pdb formats) +AC_ARG_ENABLE(pdb, + [ --enable-pdb=[(yes)|no]], + [ enable_pdb="$enableval"],[enable_pdb="yes"]) + if test "$enable_pdb" != "no" ; then + AC_DEFINE(PDBFMTS_ENABLED, 1, [1 to enable Palm PDB support]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + +AC_MSG_CHECKING(whether to support csv formats) +AC_ARG_ENABLE(csv, + [ --enable-csv=[(yes)|no]], + [ enable_csv="$enableval"],[enable_csv="yes"]) + if test "$enable_csv" != "no" ; then + AC_DEFINE(CSVFMTS_ENABLED, 1, [1 to enable the CSV formats support]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + +AC_MSG_CHECKING(whether to support csv formats) +AC_ARG_ENABLE(filters, + [ --enable-filters=[(yes)|no]], + [ enable_filters="$enableval"],[enable_filters="yes"]) + if test "$enable_filters" != "no" ; then + AC_DEFINE(FILTERS_ENABLED, 1, [1 to enable all the filters.]) + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + case "$target" in *-*-cygwin* | *-*-mingw32*) @@ -91,31 +133,48 @@ AC_SUBST(GBSER) AC_MSG_CHECKING(for random stuff to make you feel better) AC_MSG_RESULT(failed) -AC_MSG_CHECKING(for libexpat) -if test "$with_libexpat" = no ; then - AC_MSG_RESULT(check not done) -else +AC_ARG_WITH(expathdr, + [ --with-expathdr[=DIR] Use this to specify the location of expat.h], + [ xpathdr="$withval" ], [ + case "$target" in + *-*-darwin*) + if test -f /sw/include/expat.h ; then + xpathdr=/sw/include/ + fi + ;; + *) ;; + esac +] +) + +if test "x-$xpathdr " != "x-" ; then + CFLAGS="$CFLAGS -I$xpathdr" +fi -# Special case fink test. +AC_MSG_CHECKING(for libexpat) +AC_ARG_WITH(libexpat, + [ --with-libexpat[=DIR] Use this to specify expat library .], + [ EXPAT_LIB="-L$withval -lexpat"], [ case "$target" in *-*-darwin*) - if test -f /sw/include/expat.h -a -f /sw/include/expat.h; then - CFLAGS="$CFLAGS -I/sw/include" - LDFLAGS="$LDFLAGS -L/sw/lib" - # Static link against expat archive, not dyn lib. - AC_DEFINE(HAVE_LIBEXPAT, 1, [Defined if you have libexpat]) + if test -f /sw/lib/libexpat.a ; then EXPAT_LIB=/sw/lib/libexpat.a fi ;; *) - AC_CHECK_LIB([expat], [XML_ParserCreate], - AC_DEFINE(HAVE_LIBEXPAT, 1, [Defined if you have libexpat]) - [EXPAT_LIB="$LDFLAGS -lexpat"]) - + EXPAT_LIB=-lexpat ;; esac -fi -AC_SUBST(EXPAT_LIB) + ] +) +AC_MSG_RESULT($EXPAT_LIB) + +AC_CHECK_LIB([expat], [XML_ParserCreate], + AC_DEFINE(HAVE_LIBEXPAT, 1, [Defined if you have libexpat]) + AC_SUBST(EXPAT_LIB) +# [EXPAT_LIB="$LDFLAGS -lexpat"] +) +echo $EXPAT_LIB # Checks for header files. # AC_HEADER_STDC diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index b1d172e5f..51a90ae30 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -280,6 +280,7 @@ csv_lineparse(const char *stringstart, const char *delimited_by, return (tmp); } +#if CSVFMTS_ENABLED /*****************************************************************************/ /* dec_to_intdeg() - convert decimal degrees to integer degreees */ /* usage: i = dec_to_intdeg(31.1234, 1); */ @@ -351,7 +352,7 @@ decdir_to_dec(const char * decdir) return(rval * sign); } - +#endif /***************************************************************************** * human_to_dec() - convert a "human-readable" lat and/or lon to decimal @@ -482,6 +483,7 @@ human_to_dec( const char *instr, double *outlat, double *outlon, int which ) } } +#if CSVFMTS_ENABLED /* * dec_to_human - convert decimal degrees to human readable */ @@ -1514,4 +1516,4 @@ xcsv_data_write(void) fprintf (xcsv_file.xcsvfp, "%s%s", ogp->val, xcsv_file.record_delimiter); } } - +#endif diff --git a/gpsbabel/discard.c b/gpsbabel/discard.c index 045c12112..1b69c8c86 100644 --- a/gpsbabel/discard.c +++ b/gpsbabel/discard.c @@ -22,6 +22,7 @@ #include "defs.h" #include "filterdefs.h" +#if FILTERS_ENABLED static char *hdopopt = NULL; static char *vdopopt = NULL; static char *andopt = NULL; @@ -114,3 +115,4 @@ filter_vecs_t discard_vecs = { NULL, fix_args }; +#endif diff --git a/gpsbabel/duplicate.c b/gpsbabel/duplicate.c index bc5da9107..f40e1bf5f 100644 --- a/gpsbabel/duplicate.c +++ b/gpsbabel/duplicate.c @@ -22,6 +22,7 @@ #include "defs.h" #include "filterdefs.h" +#if FILTERS_ENABLED static char *snopt = NULL; static char *lcopt = NULL; static char *purge_duplicates = NULL; @@ -256,3 +257,4 @@ filter_vecs_t duplicate_vecs = { NULL, dup_args }; +#endif diff --git a/gpsbabel/filter_vecs.c b/gpsbabel/filter_vecs.c index 23163c422..2dc2f42a8 100644 --- a/gpsbabel/filter_vecs.c +++ b/gpsbabel/filter_vecs.c @@ -45,41 +45,52 @@ extern filter_vecs_t interpolatefilt_vecs; static fl_vecs_t filter_vec_list[] = { +#if FILTERS_ENABLED + { + &arcdist_vecs, + "arc", + "Include Only Points Within Distance of Arc", + }, { - &position_vecs, - "position", - "Remove Points Within Distance", - }, - { - &radius_vecs, - "radius", - "Include Only Points Within Radius", - }, + &discard_vecs, + "discard", + "Remove unreliable points with high hdop or vdop" + }, { &duplicate_vecs, "duplicate", "Remove Duplicates", }, - { - &arcdist_vecs, - "arc", - "Include Only Points Within Distance of Arc", + { + &interpolatefilt_vecs, + "interpolate", + "Interpolate between trackpoints" + }, + { + &nuke_vecs, + "nuketypes", + "Remove all waypoints, tracks, or routes" }, { &polygon_vecs, "polygon", "Include Only Points Inside Polygon", }, + { + &position_vecs, + "position", + "Remove Points Within Distance", + }, + { + &radius_vecs, + "radius", + "Include Only Points Within Radius", + }, { &routesimple_vecs, "simplify", "Simplify routes", }, - { - &reverse_route_vecs, - "reverse", - "Reverse stops within routes", - }, { &sort_vecs, "sort", @@ -90,26 +101,17 @@ fl_vecs_t filter_vec_list[] = { "stack", "Save and restore waypoint lists" }, + { + &reverse_route_vecs, + "reverse", + "Reverse stops within routes", + }, { &trackfilter_vecs, "track", "Manipulate track lists" }, - { - &discard_vecs, - "discard", - "Remove unreliable points with high hdop or vdop" - }, - { - &nuke_vecs, - "nuketypes", - "Remove all waypoints, tracks, or routes" - }, - { - &interpolatefilt_vecs, - "interpolate", - "Interpolate between trackpoints" - }, +#endif { NULL, NULL, diff --git a/gpsbabel/garmin_tables.c b/gpsbabel/garmin_tables.c index 06030623b..b054747b0 100644 --- a/gpsbabel/garmin_tables.c +++ b/gpsbabel/garmin_tables.c @@ -173,41 +173,15 @@ icon_mapping_t garmin_icon_table[] = { { 35, 36, "White Dot" }, { 88, 8219, "Zoo" }, - /* These are experimental and for the custom icons in the new "C" - * models. As of this writing, firmware problems impair their - * general use. - * - * "Quest" supports more icons than this, but other problems - * prohibit us from running with that model, so we stop at 24. - * - * Mapsource doesn't yet know how to do these, so we made the icon - * numbers "-2" to signify that as a problem until we can create - * these in a .mps or .gdb file and see their representation there. + /* Custom icons. The spec reserves 7680-8191 for the custom + * icons on the C units, Quest, 27xx, 276, 296, and other units. + * Note that firmware problems on the earlier unit result in these + * being mangled, so be sure you're on a version from at least + * late 2005. + * { -2, 7680, "Custom 0" }, + * .... + * { -2, 8192, "Custom 511" }, */ - { -2, 7680, "Custom 0" }, - { -2, 7681, "Custom 1" }, - { -2, 7682, "Custom 2" }, - { -2, 7683, "Custom 3" }, - { -2, 7684, "Custom 4" }, - { -2, 7685, "Custom 5" }, - { -2, 7686, "Custom 6" }, - { -2, 7687, "Custom 7" }, - { -2, 7688, "Custom 8" }, - { -2, 7689, "Custom 9" }, - { -2, 7690, "Custom 10" }, - { -2, 7691, "Custom 11" }, - { -2, 7692, "Custom 12" }, - { -2, 7693, "Custom 13" }, - { -2, 7694, "Custom 14" }, - { -2, 7695, "Custom 15" }, - { -2, 7696, "Custom 16" }, - { -2, 7697, "Custom 17" }, - { -2, 7698, "Custom 18" }, - { -2, 7699, "Custom 19" }, - { -2, 7700, "Custom 20" }, - { -2, 7701, "Custom 21" }, - { -2, 7702, "Custom 22" }, - { -2, 7703, "Custom 23" }, { 92, 8227, "Micro-Cache" }, /* icon for "Toll Booth" */ { 48, 161, "Virtual cache" }, /* icon for "Scenic Area" */ @@ -544,7 +518,7 @@ char * gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, int *dynamic) { icon_mapping_t *i; - char custom[] = "Custom 63"; + char custom[] = "Custom 63 "; if ((garmin_format == GDB) && (icon >= 500) && (icon <= 563)) { @@ -553,6 +527,12 @@ gt_find_desc_from_icon_number(const int icon, garmin_formats_e garmin_format, in return xstrdup(custom); } + if ((garmin_format == PCX) && (icon >= 7680) && (icon <= 8191)) { + snprintf(custom, sizeof(custom), "Custom %d", icon - 7680); + *dynamic = 1; + return xstrdup(custom); + } + if (dynamic) *dynamic = 0; for (i = garmin_icon_table; i->icon; i++) { @@ -592,11 +572,16 @@ int gt_find_icon_number_from_desc(const char *desc, garmin_formats_e garmin_form return n; } - if ((garmin_format == GDB) && (case_ignore_strncmp(desc, "Custom ", 7) == 0)) { - n = atoi((char *)desc + 7); - if ((n >= 0) && (n <= 63)) - return n+500; + if (0 == case_ignore_strncmp(desc, "Custom ", 7)) { + int base = 0; + if (garmin_format == GDB) base = 500; + if (garmin_format == PCX) base = 7680; + if (base) { + n = atoi(&desc[7]); + return n + base; + } } + for (i = garmin_icon_table; i->icon; i++) { if (case_ignore_strcmp(desc,i->icon) == 0) { switch (garmin_format) { diff --git a/gpsbabel/garmin_txt.c b/gpsbabel/garmin_txt.c index caeea30b5..e8090943c 100644 --- a/gpsbabel/garmin_txt.c +++ b/gpsbabel/garmin_txt.c @@ -22,6 +22,7 @@ #include "defs.h" +#if CSVFMTS_ENABLED #include #include #include @@ -500,7 +501,8 @@ print_categories(gbuint16 categories) fprintf(fout, "%s", (count++ > 0) ? "," : ""); if (c == NULL) - fprintf(fout, "Category %d", i+1); +// fprintf(fout, "Category %d", i+1); + fprintf(fout, "%s", gps_categories[i]); else fprintf(fout, "%s", c); @@ -1388,3 +1390,5 @@ ff_vecs_t garmin_txt_vecs = { garmin_txt_args, CET_CHARSET_MS_ANSI, 0 }; + +#endif // CSVFMTS_ENABLED diff --git a/gpsbabel/gpx.c b/gpsbabel/gpx.c index 348e05f57..062950bb4 100644 --- a/gpsbabel/gpx.c +++ b/gpsbabel/gpx.c @@ -1047,13 +1047,14 @@ gpx_rd_deinit(void) #else /* NO_EXPAT */ static void -gpx_cdata(void *dta, const XML_Char *s, int len) +gpx_cdata(void *dta, const XML_Char *xml_el, int len) { char *estr; int *cdatalen; char **cdata; xml_tag *tmp_tag; size_t slen = strlen(cdatastr.mem); + const char *s = xml_convert_to_char_string_n(xml_el, &len); vmem_realloc(&cdatastr, 1 + len + slen); estr = ((char *) cdatastr.mem) + slen; @@ -1085,6 +1086,8 @@ gpx_cdata(void *dta, const XML_Char *s, int len) memcpy( estr, s, len ); *(estr+len) = '\0'; *cdatalen += len; + + xml_free_converted_string(s); } static void diff --git a/gpsbabel/internal_styles.c b/gpsbabel/internal_styles.c index ab4e2cf41..69dc534b0 100644 --- a/gpsbabel/internal_styles.c +++ b/gpsbabel/internal_styles.c @@ -1,6 +1,8 @@ /* This file is machine-generated from the contents of style/ */ /* by mkstyle.sh. Editing it by hand is an exeedingly bad idea. */ +#include "defs.h" +#if CSVFMTS_ENABLED static char arc[] = "# gpsbabel XCSV style file\n" "#\n" @@ -851,6 +853,40 @@ static char tabsep[] = "IFIELD GEOCACHE_PLACER,\"\",\"%s\"\n" "IFIELD YYYYMMDD_TIME,\"\",\"%ld\"\n" ; +static char xmap[] = +"# gpsbabel XCSV style file\n" +"#\n" +"# Format: DeLorme Xmap Conduit\n" +"# Author: Alex Mottram\n" +"# Date: 12/09/2002\n" +"#\n" +"# \n" +"# As defined in csv.c/xmap\n" +"#\n" + +"DESCRIPTION DeLorme XMap HH Native .WPT\n" +"EXTENSION wpt\n" + +"#\n" +"# FILE LAYOUT DEFINITIIONS:\n" +"#\n" +"FIELD_DELIMITER COMMASPACE\n" +"RECORD_DELIMITER NEWLINE\n" +"BADCHARS COMMA\n" + +"PROLOGUE BEGIN SYMBOL\n" +"EPILOGUE END\n" +"#\n" +"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n" +"#\n" +"IFIELD LAT_HUMAN_READABLE, \"\", \"%08.5f\"\n" +"IFIELD LON_HUMAN_READABLE, \"\", \"%08.5f\"\n" +"IFIELD DESCRIPTION, \"\", \"%s\"\n" + +"OFIELD LAT_DECIMAL, \"\", \"%08.5f\"\n" +"OFIELD LON_DECIMAL, \"\", \"%08.5f\"\n" +"OFIELD DESCRIPTION, \"\", \"%s\"\n" +; static char xmap2006[] = "# gpsbabel XCSV style file\n" "#\n" @@ -889,40 +925,6 @@ static char xmap2006[] = -; -static char xmap[] = -"# gpsbabel XCSV style file\n" -"#\n" -"# Format: DeLorme Xmap Conduit\n" -"# Author: Alex Mottram\n" -"# Date: 12/09/2002\n" -"#\n" -"# \n" -"# As defined in csv.c/xmap\n" -"#\n" - -"DESCRIPTION DeLorme XMap HH Native .WPT\n" -"EXTENSION wpt\n" - -"#\n" -"# FILE LAYOUT DEFINITIIONS:\n" -"#\n" -"FIELD_DELIMITER COMMASPACE\n" -"RECORD_DELIMITER NEWLINE\n" -"BADCHARS COMMA\n" - -"PROLOGUE BEGIN SYMBOL\n" -"EPILOGUE END\n" -"#\n" -"# INDIVIDUAL DATA FIELDS, IN ORDER OF APPEARANCE:\n" -"#\n" -"IFIELD LAT_HUMAN_READABLE, \"\", \"%08.5f\"\n" -"IFIELD LON_HUMAN_READABLE, \"\", \"%08.5f\"\n" -"IFIELD DESCRIPTION, \"\", \"%s\"\n" - -"OFIELD LAT_DECIMAL, \"\", \"%08.5f\"\n" -"OFIELD LON_DECIMAL, \"\", \"%08.5f\"\n" -"OFIELD DESCRIPTION, \"\", \"%s\"\n" ; static char xmapwpt[] = "# gpsbabel XCSV style file\n" @@ -956,6 +958,9 @@ static char xmapwpt[] = "IFIELD IGNORE, \"\", \"%-.31s\"\n" "IFIELD DESCRIPTION, \"\", \"%-.78s\"\n" ; -#include "defs.h" -style_vecs_t style_list[] = {{ "xmapwpt", xmapwpt } , { "xmap", xmap } , { "xmap2006", xmap2006 } , { "tabsep", tabsep } , { "saplus", saplus } , { "s_and_t", s_and_t } , { "openoffice", openoffice } , { "nima", nima } , { "mxf", mxf } , { "mapconverter", mapconverter } , { "kwf2", kwf2 } , { "ktf2", ktf2 } , { "gpsman", gpsman } , { "gpsdrivetrack", gpsdrivetrack } , { "gpsdrive", gpsdrive } , { "geonet", geonet } , { "garmin_poi", garmin_poi } , { "garmin301", garmin301 } , { "fugawi", fugawi } , { "dna", dna } , { "custom", custom } , { "cup", cup } , { "csv", csv } , { "cambridge", cambridge } , { "arc", arc } , {0,0}}; +style_vecs_t style_list[] = {{ "xmapwpt", xmapwpt } , { "xmap2006", xmap2006 } , { "xmap", xmap } , { "tabsep", tabsep } , { "saplus", saplus } , { "s_and_t", s_and_t } , { "openoffice", openoffice } , { "nima", nima } , { "mxf", mxf } , { "mapconverter", mapconverter } , { "kwf2", kwf2 } , { "ktf2", ktf2 } , { "gpsman", gpsman } , { "gpsdrivetrack", gpsdrivetrack } , { "gpsdrive", gpsdrive } , { "geonet", geonet } , { "garmin_poi", garmin_poi } , { "garmin301", garmin301 } , { "fugawi", fugawi } , { "dna", dna } , { "custom", custom } , { "cup", cup } , { "csv", csv } , { "cambridge", cambridge } , { "arc", arc } , {0,0}}; size_t nstyles = 25; +#else /* CSVFMTS_ENABLED */ +style_vecs_t style_list[] = {{0,0}}; +size_t nstyles = 0; +#endif /* CSVFMTS_ENABLED */ diff --git a/gpsbabel/interpolate.c b/gpsbabel/interpolate.c index 189750d3c..fe4659d27 100644 --- a/gpsbabel/interpolate.c +++ b/gpsbabel/interpolate.c @@ -23,6 +23,7 @@ #include "filterdefs.h" #include "grtcirc.h" +#if FILTERS_ENABLED #define MYNAME "Interpolate filter" static char *opt_interval = NULL; @@ -162,3 +163,4 @@ filter_vecs_t interpolatefilt_vecs = { NULL, interpfilt_args }; +#endif FILTERS_ENABLED diff --git a/gpsbabel/jeeps/gps.h b/gpsbabel/jeeps/gps.h index 35062287b..e307b3aba 100644 --- a/gpsbabel/jeeps/gps.h +++ b/gpsbabel/jeeps/gps.h @@ -33,6 +33,7 @@ extern int32 gps_warning; extern int32 gps_error; extern int32 gps_user; extern int32 gps_show_bytes; +extern char gps_categories[16][17]; typedef struct GPS_SPacket diff --git a/gpsbabel/jeeps/gpsapp.c b/gpsbabel/jeeps/gpsapp.c index 08e4ee7a0..204d198b9 100644 --- a/gpsbabel/jeeps/gpsapp.c +++ b/gpsbabel/jeeps/gpsapp.c @@ -1713,7 +1713,7 @@ static void GPS_D155_Get(GPS_PWay *way, UC *s) * as of this writing for no data type exposes more than 16 bits in the * bitmask of categories. */ -static char categories[16][17]; +char gps_categories[16][17]; /* * Read descriptor s into category number N; */ @@ -1728,9 +1728,9 @@ void GPS_D120_Get(int cat_num, char *s) */ if (*s) { - strncpy(categories[cat_num], s, sizeof (categories[0])); + strncpy(gps_categories[cat_num], s, sizeof (gps_categories[0])); } else { - snprintf(categories[cat_num], sizeof (categories[0]), + snprintf(gps_categories[cat_num], sizeof (gps_categories[0]), "Category %d", cat_num+1); } } diff --git a/gpsbabel/mingw/Makefile b/gpsbabel/mingw/Makefile index cea6fe3ab..32837c31c 100644 --- a/gpsbabel/mingw/Makefile +++ b/gpsbabel/mingw/Makefile @@ -7,7 +7,7 @@ FILES=gpsbabel.exe libexpat.dll ../win32/GPSBabelGUI.exe ../win32/gui-2/README.g gpsbabel.exe: wintesto.cmd include ../Makefile -CFLAGS=-Iinclude -I../coldsync -O $(INHIBIT_USB) +CFLAGS=-Iinclude -I../coldsync -O $(INHIBIT_USB) $(EXTRA_CFLAGS) # # Must define empty (don't comment out the whole line) if you want to # override INHIBIT_USB from the parent Makefile. diff --git a/gpsbabel/mkstyle.sh b/gpsbabel/mkstyle.sh index 418e60f05..19db383a3 100755 --- a/gpsbabel/mkstyle.sh +++ b/gpsbabel/mkstyle.sh @@ -3,6 +3,8 @@ echo "/* This file is machine-generated from the contents of style/ */" echo "/* by mkstyle.sh. Editing it by hand is an exeedingly bad idea. */" echo +echo "#include \"defs.h\"" +echo "#if CSVFMTS_ENABLED" nstyles="0" for i in style/*.style do @@ -15,7 +17,10 @@ do echo ";" nstyles=`expr $nstyles + 1`; done - -echo "#include \"defs.h\"" echo "style_vecs_t style_list[] = {$ALIST {0,0}};" echo "size_t nstyles = $nstyles;" +echo "#else /* CSVFMTS_ENABLED */" +echo "style_vecs_t style_list[] = {{0,0}};" +echo "size_t nstyles = 0;" +echo "#endif /* CSVFMTS_ENABLED */" + diff --git a/gpsbabel/nukedata.c b/gpsbabel/nukedata.c index 516ad7409..6dc8fccbb 100644 --- a/gpsbabel/nukedata.c +++ b/gpsbabel/nukedata.c @@ -23,6 +23,7 @@ #include "defs.h" #include "filterdefs.h" +#if FILTERS_ENABLED #define MYNAME "nukedata" static char *nukewpts, *nuketrks, *nukertes; @@ -60,3 +61,4 @@ filter_vecs_t nuke_vecs = { nuke_args }; +#endif diff --git a/gpsbabel/polygon.c b/gpsbabel/polygon.c index 6a4a652d9..c19488d92 100644 --- a/gpsbabel/polygon.c +++ b/gpsbabel/polygon.c @@ -21,6 +21,7 @@ #include "defs.h" #include "filterdefs.h" +#if FILTERS_ENABLED #define MYNAME "Polygon filter" static char *polyfileopt = NULL; @@ -295,3 +296,4 @@ filter_vecs_t polygon_vecs = { NULL, polygon_args }; +#endif // FILTERS_ENABLED diff --git a/gpsbabel/position.c b/gpsbabel/position.c index 25f6f7d41..c9b12d9e7 100644 --- a/gpsbabel/position.c +++ b/gpsbabel/position.c @@ -22,6 +22,8 @@ #include "filterdefs.h" #include "grtcirc.h" +#if FILTERS_ENABLED + #ifndef M_PI # define M_PI 3.14159265358979323846 #endif @@ -414,3 +416,4 @@ filter_vecs_t radius_vecs = { NULL, radius_args }; +#endif // FILTERS_ENABLED diff --git a/gpsbabel/reverse_route.c b/gpsbabel/reverse_route.c index 6bc204f2e..5636cf6fa 100644 --- a/gpsbabel/reverse_route.c +++ b/gpsbabel/reverse_route.c @@ -21,6 +21,8 @@ #include "defs.h" #include "filterdefs.h" +#if FILTERS_ENABLED + #define MYNAME "Route reversal filter" static @@ -65,3 +67,4 @@ filter_vecs_t reverse_route_vecs = { NULL, reverse_route_args }; +#endif diff --git a/gpsbabel/sort.c b/gpsbabel/sort.c index 790faa299..fa8d7e519 100644 --- a/gpsbabel/sort.c +++ b/gpsbabel/sort.c @@ -21,6 +21,8 @@ #include "defs.h" #include "filterdefs.h" +#if FILTERS_ENABLED + typedef enum { sm_unknown = 0, sm_gcid, @@ -111,3 +113,4 @@ filter_vecs_t sort_vecs = { NULL, sort_args }; +#endif FILTERS_ENABLED diff --git a/gpsbabel/stackfilter.c b/gpsbabel/stackfilter.c index 137e85b50..e8bbf71e6 100644 --- a/gpsbabel/stackfilter.c +++ b/gpsbabel/stackfilter.c @@ -22,6 +22,8 @@ #include "defs.h" #include "filterdefs.h" +#if FILTERS_ENABLED + #define MYNAME "Stack filter" static char *opt_push = NULL; @@ -244,3 +246,5 @@ filter_vecs_t stackfilt_vecs = { stackfilt_exit, stackfilt_args }; + +#endif // FILTERS_ENABLED diff --git a/gpsbabel/trackfilter.c b/gpsbabel/trackfilter.c index ef4bf3c89..00c7748ae 100644 --- a/gpsbabel/trackfilter.c +++ b/gpsbabel/trackfilter.c @@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */ - /* 2005-07-20: implemented interval option from Etienne Tasse 2005-07-26: implemented range option @@ -38,6 +37,7 @@ #include "strptime.h" #include "grtcirc.h" +#if FILTERS_ENABLED #define MYNAME "trackfilter" #define TRACKFILTER_PACK_OPTION "pack" @@ -870,3 +870,4 @@ filter_vecs_t trackfilter_vecs = { }; /******************************************************************************************/ +#endif // FILTERS_ENABLED diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index fa96a7ab6..6c00fde61 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -106,6 +106,7 @@ extern ff_vecs_t yahoo_vecs; static vecs_t vec_list[] = { +#if CSVFMTS_ENABLED /* XCSV must be the first entry in this table. */ { &xcsv_vecs, @@ -113,6 +114,7 @@ vecs_t vec_list[] = { "? Character Separated Values", NULL }, +#endif { &geo_vecs, "geo", @@ -513,12 +515,14 @@ vecs_t vec_list[] = { "pdb" }, #endif +#if CSVFMTS_ENABLED { &compegps_vecs, "compegps", "CompeGPS data files (.wpt/.trk/.rte)", NULL }, +#endif //CSVFMTS_ENABLED { &yahoo_vecs, "yahoo", @@ -537,12 +541,14 @@ vecs_t vec_list[] = { "GPS TrackMaker", "gtm" }, +#if CSVFMTS_ENABLED { &garmin_txt_vecs, "garmin_txt", "Garmin MapSource - txt (tab delimited)", "txt" }, +#endif // CSVFMTS_ENABLED { &axim_gpb_vecs, "axim_gpb", @@ -669,6 +675,10 @@ find_vec(char *const vecname, char **opts) char *svecname = strtok(v, ","); int found = 0; + if (vecname == NULL) { + fatal("A format name is required.\n"); + } + while (vec->vec) { arglist_t *ap; char *res; diff --git a/gpsbabel/xcsv.c b/gpsbabel/xcsv.c index 72e77b113..1b6d114a2 100644 --- a/gpsbabel/xcsv.c +++ b/gpsbabel/xcsv.c @@ -27,6 +27,7 @@ #include "defs.h" #include "csv_util.h" +#if CSVFMTS_ENABLED #define MYNAME "XCSV" #define ISSTOKEN(a,b) (strncmp(a,b, strlen(b)) == 0) @@ -592,3 +593,7 @@ ff_vecs_t xcsv_vecs = { xcsv_args, CET_CHARSET_ASCII, 0 /* CET-REVIEW */ }; +#else +void xcsv_read_internal_style(const char *style_buf) {} +void xcsv_setup_internal_style(const char *style_buf) {} +#endif //CSVFMTS_ENABLED diff --git a/gpsbabel/xmlgeneric.c b/gpsbabel/xmlgeneric.c index e12b088fc..235524291 100644 --- a/gpsbabel/xmlgeneric.c +++ b/gpsbabel/xmlgeneric.c @@ -219,7 +219,7 @@ static void xml_cdata(void *dta, const XML_Char *xml_s, int len) { char *estr; - const char *s = xml_convert_to_char_string(xml_s); + const char *s = xml_convert_to_char_string_n(xml_s, &len); vmem_realloc(&cdatastr, 1 + len + strlen(cdatastr.mem)); estr = (char *) cdatastr.mem + strlen(cdatastr.mem); -- 2.30.2